/*
	jumper : Copyright 2011 Dale J Williams

	Licensed under the Apache License, Version 2.0 (the "License");
	you may not use this file except in compliance with the License.
	You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0

	Unless required by applicable law or agreed to in writing, software
	distributed under the License is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	See the License for the specific language governing permissions and
	limitations under the License.
*/
package lads.jumper {
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import lads.flad.scene.GameScene;
	import lads.jumper.entities.JumpCam;
	import lads.jumper.entities.Player;
	import lads.jumper.library.Library;
	import lads.jumper.pixmap.PixMap;
	
	public class JumpScene extends GameScene {
		
		private var _map	:PixMap;
		private var player	:Player;
		
		public function JumpScene() {
			super("jumpScene");
			
			_map = new PixMap();
			map.scale = 80;
			
			setCamera(new JumpCam());
			
			player = new Player();
		}
		
		public function awake():void {
			addLayer("map");
			addLayer("entities");
			
			addToScene(map, "map");
			addToScene(player, "entities");
			
			camera.target = player;
		}
		
		override protected function updateScreen():void {
			camera.bounds.left = (screen.width * 0.5) / camera.zoom;
			camera.bounds.right = (map.width - screen.width * 0.5) / camera.zoom;
			super.updateScreen();
		}
		
		public function start():void {
			loadMap((new Library.Map() as Bitmap).bitmapData);
			player.x = map.startP.x * map.scaleX + 100;
			player.y = map.startP.y * map.scaleY + 75;
		}
		
		public function loadMap(bitmapData:BitmapData):void {
			map.bitmapData = bitmapData;
		}
		
		public function get map():PixMap { return _map; }
		
	}

}